//
//  ZBFrameRatioFitTool.m
//  ZBMainFramework
//
//  Created by apple on 2018/10/26.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "ZBFrameRatioFitTool.h"

@implementation ZBFrameRatioFitTool


/**
 自动比例调节宽度
 */
CGFloat zbAutoAdjustWidth(CGFloat originalWidth)
{
    CGFloat rate = getCurrentScreenWidth()/get6sScreenWidth();
    CGFloat newWidth = rate * originalWidth;
    return newWidth;
}

/**
 自动比例调节高度
 */
CGFloat zbAutoAdjustHeight(CGFloat originalHeight)
{
    CGFloat rate = getCurrentScreenHeight()/get6sScreenHeight();
    CGFloat newHeight = rate * originalHeight;
    return newHeight;
}

/**
 导航条高度
 */
CGFloat zbDeviceNavagationBarHight(void)
{
    CGFloat height = 44;
    return height;
}
/**
 状态栏高度
 */
CGFloat zbDeviceStatusBarHight(void)
{
    CGFloat height = 20;
    if(isIphoneXfromScreen() ||isIphoneXRfromScreen()){
        height = 44;
    }
    return height;
}
/**
 tabbar高度
 */
CGFloat zbDeviceTabBarHight(void)
{
    return 49.0;
}
/**
 导航高度
 */
CGFloat zbDeviceNavagationHight(void)
{
    return zbDeviceStatusBarHight() + zbDeviceNavagationBarHight();
}


CGFloat getCurrentScreenWidth(){
    UIScreen *screen = [UIScreen mainScreen];
    return screen.bounds.size.width;
}
CGFloat getCurrentScreenHeight(){
    UIScreen *screen = [UIScreen mainScreen];
    return screen.bounds.size.height;
}
CGFloat get6sScreenWidth()
{
    return 375.0;
}
CGFloat get6sScreenHeight()
{
    return 667.0;
}

#pragma mark - 通过尺寸判断设备

BOOL isIphone4fromScreen(void)
{
    return (([UIScreen mainScreen].bounds.size.width == 320) && ([UIScreen mainScreen].bounds.size.height == 480)) || (([UIScreen mainScreen].bounds.size.width == 480) && ([UIScreen mainScreen].bounds.size.height == 320));
}
BOOL isIphone5fromScreen(void)
{
    return (([UIScreen mainScreen].bounds.size.width == 320) && ([UIScreen mainScreen].bounds.size.height == 568)) || (([UIScreen mainScreen].bounds.size.width == 568) && ([UIScreen mainScreen].bounds.size.height == 320));
}
BOOL isIphone6fromScreen(void)
{
   return  (([UIScreen mainScreen].bounds.size.width == 375) && ([UIScreen mainScreen].bounds.size.height == 667)) || (([UIScreen mainScreen].bounds.size.width == 667) && ([UIScreen mainScreen].bounds.size.height == 375));
}
BOOL isIphone6PlusfFromScreen(void)
{
   return (([UIScreen mainScreen].bounds.size.width == 414) && ([UIScreen mainScreen].bounds.size.height == 736)) || (([UIScreen mainScreen].bounds.size.width == 736) && ([UIScreen mainScreen].bounds.size.height == 414));
}
BOOL isIphoneXfromScreen(void)
{
    return (([UIScreen mainScreen].bounds.size.width == 375) && ([UIScreen mainScreen].bounds.size.height == 812)) || (([UIScreen mainScreen].bounds.size.width == 812) && ([UIScreen mainScreen].bounds.size.height == 375));
}
BOOL isIphoneXRfromScreen(void){
    return (([UIScreen mainScreen].bounds.size.width == 414) && ([UIScreen mainScreen].bounds.size.height == 896)) || (([UIScreen mainScreen].bounds.size.width == 896) && ([UIScreen mainScreen].bounds.size.height == 414));
}


@end
